package com.central.scheduler.dao.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.central.db.mapper.SuperMapper;
import com.central.scheduler.common.enums.ExecutionStatus;
import com.central.scheduler.common.enums.Flag;
import com.central.scheduler.dao.entity.ExecuteStatusCount;
import com.central.scheduler.dao.model.TaskInstance;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author Tindy
 * @date 2021/11/1
 * @describe
 */
@Mapper
public interface TaskInstanceMapper extends SuperMapper<TaskInstance>{

    List<Long> queryTaskByProcessIdAndState(@Param("processInstanceId") Long processInstanceId,
                                               @Param("state") Integer state);

    List<TaskInstance> findValidTaskListByProcessId(@Param("processInstanceId") Long processInstanceId,
                                                    @Param("flag") Flag flag);

    List<TaskInstance> queryByHostAndStatus(@Param("host") String host,
                                            @Param("states") ExecutionStatus[] stateArray);

    List<TaskInstance> findByProcessInsIds(@Param("processInstIds") List<Long> ids);

    List<TaskInstance> queryTaskInstances(Page<TaskInstance> page, @Param("u") Map<String, Object> params);

    List<TaskInstance> findTaskInstances(@Param("proId")Long proId, @Param("processInstanceId") Long processInstanceId);
}
